<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 用户输入一个整数n，计算n的阶乘。即n*(n-1)*(n-2)*……*3*2*1 */
        var n = prompt("计算n的阶乘，请输入一个数：" );
        var result = 1;
        for(var i = n; i >= 1; i--) {
            result *= i;
        }
        alert("n的阶乘为" + result);
         
    </script>
</body>
</html>